<template>
	<view>
		<swiper class="uswiper" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="item in ShopInfo.detail_images_arr" :key="item.id">
				<image class="uimage" :src="item" mode="aspectFill"></image>
			</swiper-item>
		</swiper>
		<view class="Shop_info">
			<view class="info_title">{{ShopInfo.name}}</view>
			<view class="info_time">店铺简介：<span>{{ShopInfo.shop_content}}</span></view>
			<view class="info_time">营业时间：<span>{{ShopInfo.trade_time_text?ShopInfo.trade_time_text:'暂无营业时间'}}</span>
			</view>
			<view class="info_address">
				店铺地址：<span>{{ShopInfo.address}}</span>
			</view>
			<view class="info_label">
				<view class="label_item" v-for="item in ShopInfo.shop_label" :key="item.id">{{item}}</view>

			</view>
			<view class="Bottom_solid"></view>
		</view>
		<view class="Shop_host">
			<view class="host_title">店内主推</view>
			<view class="" v-if="List.length>=1">
				<view class="host_list" v-for="item in List" :key="item.id" @click="goDetail(item)">
					<image class="host_img" :src="item.pic_image"></image>
					<view class="host_right">
						<view class="r_title">{{item.name}}</view>
						<view class="r_money">￥{{item.price}}/位</view>
						<view class="r_desc">
							<view class="" v-if="sindex<=3" v-for="(sitem,sindex) in item.product_label" :key="Sindex">
								{{sitem}}
							</view>
						</view>
					</view>
				</view>
			</view>

			<view class="none" v-else>
				<image class="none_img" src="../../static/home/none.png" mode=""></image>
				<view class="">暂未收入，敬请期待!</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		req_ProductByShop
	} from '../../utls/api.js'
	export default {
		data() {
			return {
				ShopInfo: uni.getStorageSync('ShopDetail'),
				List: [],
			}
		},
		onLoad(e) {
			console.log(uni.getStorageSync('ShopDetail'))
			if (e.share_id) {
				uni.setStorageSync('share_id', e.share_id);
				console.log(e.share_id)
			}
		},
		onShow() {
			if (uni.getStorageSync('info').is_vip == 1) {
				uni.showShareMenu({
					withShareTicket: true,
					menus: ['shareAppMessage', 'shareTimeline'] //开启转发好友和转发朋友圈按钮
				});
			} else {
				uni.hideShareMenu({
					hideShareItems: ['shareTimeline', 'shareMenu']
				})
			}
		},
		onShareAppMessage: function(e) { // 分享到微信
			// 更多参数配置，参考文档
			let path = getCurrentPages();
			let route = path[path.length - 1].route;
			console.log(route, uni.getStorageSync('info').share_id)
			return {
				title: '同城泉友',
				path: `/${route}?share_id=${uni.getStorageSync('info').share_id}`,
			}
		},

		onShareTimeline() { // 分享到朋友圈
			let path = getCurrentPages();
			let route = path[path.length - 1].route;
			return {
				title: '同城泉友',
				path: `/${route}?share_id=${uni.getStorageSync('info').share_id}`,
			}
		},
		mounted() {
			this.getProduct()
		},
		methods: {
			getProduct() {
				console.log(this.ShopInfo.id)
				req_ProductByShop({
					shop_id: this.ShopInfo.id,
				}).then(res => {
					console.log(res);
					if (res.data.code == 1) {
						this.List = res.data.data;
					} else {
						console.log("无数据或接口请求错误")
					}
				})
			},
			goDetail(item) {
				uni.setStorageSync('Detail', item)
				uni.navigateTo({
					url: '../index/Detail',
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.uswiper {
		width: 100%;
		height: 300rpx;
	}

	.uimage {
		width: 100%;
		height: 300rpx;
	}

	.Shop_info {
		padding: 20rpx;

		.info_title {
			font-size: 32rpx;
			font-weight: 700;
			margin-bottom: 20rpx;
		}

		.info_time {
			font-size: 26rpx;
			margin-bottom: 5rpx;
			color: #000;

			>span {
				font-weight: 400;
				color: #333;
			}
		}

		.info_address {
			font-size: 26rpx;
			color: #000;

			>span {
				font-weight: 400;
				color: #333;
			}

			margin-bottom: 15rpx;
		}

		.info_label {
			display: flex;
			margin-bottom: 10rpx;

			.label_item {
				padding: 5rpx 10rpx;
				border-radius: 8rpx;
				color: white;
				font-size: 24rpx;
				background-color: #EDB843;
				margin-right: 10rpx;
			}
		}
	}

	.Shop_host {
		padding: 00rpx 20rpx 20rpx 20rpx;

		.host_title {
			font-size: 30rpx;
			font-weight: 600;
		}

		.host_list {
			display: flex;
			align-items: center;
			margin: 20rpx 0;
			box-shadow: 0 0 15rpx 10rpx #f1f1f1;
			border-radius: 10rpx;
			padding: 10rpx;

			.host_img {
				width: 150rpx;
				height: 150rpx;
				border-radius: 10rpx;
				min-width: 170rpx;
				margin-right: 20rpx;
			}

			.host_right {
				width: calc(100% - 170rpx);

				.r_title {
					font-size: 30rpx;
					font-weight: 600;
					margin-bottom: 10rpx;
				}

				.r_money {
					font-size: 24rpx;
					font-weight: 600;
					color: #EDB843;
					margin-top: 15rpx;
				}

				.r_desc {
					font-size: 20rpx;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					color: #999999;
					display: flex;
					margin-top: 5rpx;

					>view {
						padding: 5rpx 10rpx;
						border-radius: 8rpx;
						color: white;
						background-color: #EDB843;
						margin-right: 10rpx;
					}
				}
			}
		}
	}

	.Bottom_solid {
		margin-top: 20rpx;
		background-color: #f4f4f4;
		height: 2rpx;
		width: 100%;
	}

	.none {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-top: 30rpx;

		.none_img {
			width: 150rpx;
			height: 150rpx;
			margin-bottom: 20rpx;
		}
	}
</style>